<template>
  <list-detail-layout >
    <template #detailMain >
      <add-car-to-task dataAdress="newTaskData"></add-car-to-task>
    </template>
    <template #detailRight>
      <detail-task-base-infor :upgrade-trigger-type="upgradeTriggerType"></detail-task-base-infor>
    </template>
  </list-detail-layout>
</template>
<script>
import ListDetailLayout from '@/views/components/ListDetailLayout'
import AddCarToTask from './AddCarToTask'
import DetailTaskBaseInfor from './DetailTaskBaseInfor.vue'
import { mapState } from 'vuex'
export default {
  name: 'NewTaskStep2',
  components: {
    ListDetailLayout,
    AddCarToTask,
    DetailTaskBaseInfor
  },
  computed: {
    ...mapState({
      newTaskDataAll: (state) => state.newTask.newTaskData
    }),
    newTaskData(){
      return this.newTaskDataAll[this.upgradeTriggerType];
    }
  },
  props: {
    upgradeTriggerType : ''
  },
  data () {
    return {
    }
  },
  methods: {
    getFormValid () {
      const vm = this
      return new Promise((resolve) => {
        if (vm.newTaskData.choseType === 2 && !vm.newTaskData.pretreatmentId) {
          vm.$message.warning(vm.$t('pleaseUpload'))
          return
        }
        if (vm.newTaskData.choseType === 2 && vm.newTaskData.fileSuccessCar === 0) {
          vm.$message.warning(vm.$t('pleaseUpload'))
          return
        }
        // 验证是否选择车辆
        const selectCarNum = vm.newTaskData.isSlefSelect
          ? vm.newTaskData.selectCarIds.length : vm.newTaskData.selectCarTotal
        if (vm.newTaskData.choseType === 1 && !selectCarNum) {
          vm.$message.warning(vm.$t('pleaseSelectVehicle'))
          return
        }
        resolve()
        // reject()
      })
    }

  }
}
</script>
<style lang="less" scoped>
  // 来自文件时，上传和按钮位置
  .formFileInput {
    width: calc(100% - 120px);
    margin-bottom: 18px;

    & ~ .ant-btn {
      width: 108px;
      padding: 0;
      margin-left:10px;
    }
  }
</style>
